//
//  QianliVibrateEnum.swift
//  todoios
//
//  Created by qianli on 2025/4/10.
//


import AVFoundation
import UIKit
import SwiftyUserDefaults

public enum QianliVibrateEnum {
    case error
    case success
    case warning
    //error,success,warning(这3个为连续的3次震动),
    case light
    case medium
    case heavy
    case selection
    //selection(非常轻的震动),
    case oldSchool
    //oldSchool(类似来电时的一小段持续振动)


    public func L4smXfL531Hmh91R() {
        if !Defaults[\.enableQainliImpactFeedback] {
            return
        }
        
        switch self {
        case .error:
            let generator = UINotificationFeedbackGenerator()
            generator.notificationOccurred(.error)
            
        case .success:
            let generator = UINotificationFeedbackGenerator()
            generator.notificationOccurred(.success)
            
        case .warning:
            let generator = UINotificationFeedbackGenerator()
            generator.notificationOccurred(.warning)
            
        case .light:
            let generator = UIImpactFeedbackGenerator(style: .light)
            generator.impactOccurred()
            
        case .medium:
            let generator = UIImpactFeedbackGenerator(style: .medium)
            generator.impactOccurred()
            
        case .heavy:
            let generator = UIImpactFeedbackGenerator(style: .heavy)
            generator.impactOccurred()
            
        case .selection:
            let generator = UISelectionFeedbackGenerator()
            generator.selectionChanged()
            
        case .oldSchool:
            AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
        }
    }
    
}

